package cn.fighter3.service.relationship;

import cn.fighter3.entity.relationship.Lend2;
import cn.fighter3.entity.relationship.Lend3;
import org.springframework.data.neo4j.annotation.Query;
import org.springframework.data.neo4j.repository.Neo4jRepository;

public interface Lend3Dao extends Neo4jRepository<Lend3,Long> {
    @Query("match (n:People),(m:Mscbook) where n.authorId=$fromId and m.bookId=$toId match (n)-[r:Lend]->(m) delete r")
    void deleteByNodeId(String fromId,String toId);

    @Query("match (n:People),(m:Mscbook) where n.authorId=$fromId and m.bookId=$toId create (n)-[r:Lend{lendTime:$time}]->(m) return r")
    Lend3 addLend(String fromId, String toId,String time);

    @Query("match (m:People)-[r:Lend]->(n:Mscbook) where m.authorId=$fromId and n.bookId=$toId set r.lendTime=$time return r")
    Lend3 updateLend(String fromId, String toId,String time);
}
